import Vue from 'vue'
import App from './App'
import cuCustom from './colorui/components/cu-custom.vue'
// const headUrl = 'http://8.129.181.12:9080/fxj-boot/'
const headUrl = 'http://47.113.194.153/fxj-boot/'





Vue.component('cu-custom',cuCustom)
Vue.config.productionTip = false
Vue.prototype.$headUrl = headUrl
Vue.prototype.$get = function (url,data){
	return new Promise((resolve,reject)=>{
		uni.request({
			url: this.$headUrl + url,
			data: data,
			header: {
				'X-Access-Token': uni.getStorageSync('token')
			},
			success: (res) => {
				if(res.data.status == 500){
					console.log(res.data.status);
					uni.showToast({
						title:'登录失效,请重新登录',
						icon:'none'
					})
					setTimeout(()=>{
						uni.reLaunch({
							url:'/pages/login/login'
						})
					},1000)
				}else{
					resolve(res)
				}
					resolve(res)
			}
		});
	})
}
Vue.prototype.$post = function (url,data){
	return new Promise((resolve,reject)=>{
		uni.request({
			url: this.$headUrl + url,
			data: data,
			method:'POST',
			header: {
				'X-Access-Token': uni.getStorageSync('token')
			},
			success: (res) => {
				if(res.data.status == 500){
					console.log(res.data.status);
					uni.showToast({
						title:'登录失效,请重新登录',
						icon:'none'
					})
					setTimeout(()=>{
						uni.reLaunch({
							url:'/pages/login/login'
						})
					},1000)
				}else{
					resolve(res)
				}
					resolve(res)
			}
		});
	})
}
Vue.prototype.$put = function (url,data){
	return new Promise((resolve,reject)=>{
		uni.request({
			url: this.$headUrl + url,
			data: data,
			method:'PUT',
			header: {
				'X-Access-Token': uni.getStorageSync('token')
			},
			success: (res) => {
				if(res.data.status == 500){
					console.log(res.data.status);
					uni.showToast({
						title:'登录失效,请重新登录',
						icon:'none'
					})
					setTimeout(()=>{
						uni.reLaunch({
							url:'/pages/login/login'
						})
					},1000)
				}else{
					resolve(res)
				}
					resolve(res)
			}
		});
	})
}





App.mpType = 'app'
const app = new Vue({
    ...App
})
app.$mount()
